package de.revdev.llt.module.learning.utility;

import de.revdev.llt.module.learning.LearnStatusFC;
import java.util.Comparator;

/**
 *
 * @author f.lindermaier
 */
public class LearnStatusFCComperator implements Comparator<LearnStatusFC> {

    @Override
    public int compare(LearnStatusFC o1, LearnStatusFC o2) {

        if (o1.getLearnCategory().ordinal() > o2.getLearnCategory().ordinal()) {
            return o1.getLearnCategory().ordinal() - o2.getLearnCategory().ordinal();
        } else if (o1.getLearnCategory().ordinal() < o2.getLearnCategory().ordinal()) {
            return o1.getLearnCategory().ordinal() - o2.getLearnCategory().ordinal();
        } else {
            if (o1.getLastDateAnswered().after(o2.getLastDateAnswered())) {
                return 1;
            } else if (o1.getLastDateAnswered().before(o2.getLastDateAnswered())) {
                return -1;
            } else {
                return 0;
            }
        }
    }
}
